package Register;


import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.logging.Level;
import java.util.logging.Logger;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author s0lo
 */
public class MyMD5 {

    public static String getMD5String(String input) {
        StringBuilder result = null;
        MessageDigest MD5 = null;
        try {
            MD5 = MessageDigest.getInstance("MD5");
            MD5.update(input.getBytes());
            byte[] passArr = MD5.digest();
            result = new StringBuilder();
            for (int i = 0; i < passArr.length; i++) {
                result.append(Integer.toHexString((0x000000ff & passArr[i]) | 0xffffff00).substring(6));
            }
        } catch (NoSuchAlgorithmException ex) {
            result = new StringBuilder("Can't calculate hash code");
            Logger.getLogger(MyMD5.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            return result.toString();
        }
    }
}
